cmake_minimum_required(VERSION 3.5)
PROJECT(RtspServer)

include(${CMAKE_SOURCE_DIR}/cmake/cmakebase.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/ss928.cmake)

SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY  "${CMAKE_SOURCE_DIR}/bin/${PLATFORM}")
SET(LIBRARY_OUTPUT_PATH  "${CMAKE_SOURCE_DIR}/bin/${PLATFORM}") 


add_definitions(-DALLOW_SERVER_PORT_REUSE)
add_definitions(-DSOCKLEN_T=socklen_t)
add_definitions(-D_LARGEFILE_SOURCE=1)
add_definitions(-D_FILE_OFFSET_BITS=64)
add_definitions(-D_EPOLL_)
# add_definitions(-DNO_OPENSSL)

include_directories(
  ${CMAKE_SOURCE_DIR}/src/live/BasicUsageEnvironment/include
  ${CMAKE_SOURCE_DIR}/src/live/groupsock/include
  ${CMAKE_SOURCE_DIR}/src/live/liveMedia/include
  ${CMAKE_SOURCE_DIR}/src/live/UsageEnvironment/include
)

aux_source_directory(${CMAKE_SOURCE_DIR}/src/live/BasicUsageEnvironment  LIBSRC)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/live/groupsock  LIBSRC)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/live/liveMedia  LIBSRC)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/live/UsageEnvironment  LIBSRC)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/  LIBSRC)

add_library(${PROJECT_NAME} SHARED ${LIBSRC})


set(OUTPUT_LIB_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib)
add_custom_command(
    TARGET ${PROJECT_NAME}
    POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/src/EasyTypes.h ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
    COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/src/EasyRtspServerAPI.h ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
    COMMENT "Copying lib files to output directory"
)
add_custom_target(cpfiles ALL DEPENDS  ${PROJECT_NAME})